﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace App_1Mark1
{
    public partial class Frm_Information_Personnel : Form
    {
        public Frm_Information_Personnel()
        {
            InitializeComponent();
        }

        SqlDataAdapter sda = new SqlDataAdapter();
        SqlCommand scom = new SqlCommand();
        SqlConnection sqlconnx = new SqlConnection();
        SqlCommandBuilder sqlcb = new SqlCommandBuilder();
        DataSet ds = new DataSet();
        SqlDataReader sdr;

        private void Frm_Information_Personnel_Load(object sender, EventArgs e)
        {
            sqlconnx.ConnectionString = "Data Source=DESKTOP-03S1896;Initial Catalog=Gestion_Scolarité;Integrated Security=True";
            sqlconnx.Open();
            scom.Connection = sqlconnx;
            scom.CommandText = "select * from Module";
            sda.SelectCommand = scom;
            sda.Fill(ds, "Module");
            gr_Module.DataSource = ds.Tables["Module"];
            gr_Module.Columns[0].HeaderText = "ID Module";
            gr_Module.Columns[1].HeaderText = "Nom Module";
            gr_Module.Columns[2].HeaderText = "Masse Horaire";
            lst_mat.DataSource = ds.Tables["Module"];
            lst_mat.DisplayMember = "ID_Module";
            lst_mat.ValueMember = "ID_Module";
            
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            scom.CommandText = "insert into Professeur values('" + txt_cin.Text + "','" + txt_nom.Text + "','" + txt_prenom.Text + "','" + txt_tele.Text + "'," + txt_salaire.Text + ",'" + txt_ville.Text + "')";
            scom.ExecuteNonQuery();
            scom.CommandText = "insert into Enseigner values(" + lst_mat.SelectedValue + ",'" + txt_cin.Text + "')";
            scom.ExecuteNonQuery();
            MessageBox.Show("Votre inscription est bien passée");
            txt_cin.Clear();
            txt_nom.Clear();
            txt_prenom.Clear();
            txt_tele.Clear();
            txt_salaire.Clear();
            txt_ville.Clear();
           

            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Frm_Information_Personnel frm_p = new Frm_Information_Personnel();
            frm_p.Size = new Size(748,441);
           



        }

    }
}
